#include "learn_rule.h"
#include <QIcon>
#include "mypushbutton.h"
#include <QTimer>
#include "mainscene.h"
#include <QDebug>

learn_rule::learn_rule(QWidget *parent) : QWidget(parent)
{
    //设置固定大小
    setFixedSize(550,700);
    //设置窗口图片
    setWindowIcon(QIcon(":/firstsence.jpg"));
    //设置标题
    setWindowTitle("规则介绍");

    //创建退出按钮
    QPushButton * btn1 = new QPushButton;
    btn1->setParent(this);
    btn1->setText("退出游戏");
    btn1->move(0,0);
    btn1->show();
    //点击按钮 实现退出游戏
    connect(btn1,&QPushButton::clicked,[=](){
        this->close();
    });

    //返回按钮
    MyPushButton * backBtn = new MyPushButton(":/BackButton.png",":/BackButtonSelected.png");
    backBtn->setParent(this);
    //移动到右下角
    backBtn->move(this->width() - backBtn->width(),
                  this->height() - backBtn->height());
    //点击返回
    connect(backBtn,&MyPushButton::clicked,[=](){
        //告诉游戏场景，我返回了，游戏场景监听返回按钮
        //延时返回
        QTimer::singleShot(100,this,[=](){
            emit this->chooseSceneBack();
        });
    });

}

